import axios from 'axios'
export const getlistData=(data)=>{
    return {
        type:'GETLISTS',
        payload:data
    }
}

//真正的ajax请求
export function fetchList(params={page:1}){
    return (dispatch)=>{
        const url=`http://10.31.161.18:3000/product?_page=${params.page}&_limit=20`;
        axios({
            url:url,
            method:'get',
        }).then(res=>{
            var jsonData={
                total:+res.headers['x-total-count'],
                rows:res.data
            }
            dispatch(getlistData(jsonData))
        })
    }
}